package com.ftg.learn.chapter03;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 带缓冲的
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/12/5 下午2:36
 */
public class LearnWrite {

    public static void main(String[] args) {
        File file = new File("/home/kangjx/Desktop/ruoyi/a.java");
        if(!file.exists()){
            try {
                file.createNewFile();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        try (
            FileWriter fw = new FileWriter(file);
            BufferedWriter writer = new BufferedWriter(fw);
        ) {
            writer.write("package com.ftg.learn;\n");
            writer.write("public class abc{\n");
            writer.write("  public static void main(String[] args){\n");
            writer.write("      System.out.println(\"hello world\");\n");
            writer.write("   }\n");
            writer.write("}\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    //1 给完成一个图片的复制粘贴
    //2 给我生成一段 冒泡排序代码到  **.java
    //3 两个狼在草原上跑 ,面向对象来设计 ,用io生成到你的工程所在的src 某一个包里面  (com.ftg.learn)

}
